<extend name="Public/layout"/>

<block name="body">
    <form action="__SELF__" method="post" class="form">
        <div class="form-group">
            <label class="item-label">上级分类<span class="check-tips">（所属的上级分类）</span></label>
            <div class="controls">
                <select name="pid" class="form-control">
                    <volist name="all_category" id="_category">
                        <option value="{$_category.id}" 
                            <php>if($_category['id'] == $info['pid']) echo 'selected="selected"';</php> >
                            {$_category.title_show}
                        </option>
                    </volist>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="item-label">分类标题<span class="check-tips">（分类标题）</span></label>
            <div class="controls">
                <input type="text" class="form-control" name="title" value="{$info.title|default=''}">
            </div>
        </div>
        <div class="form-group">
            <label class="item-label">分类内容模型<span class="check-tips">（分类内容模型）</span></label>
            <div class="controls">
                <select name="model" class="form-control">
                    <option value=''>请选择模型：</option>
                    <volist name="all_model" id="model">
                        <option value="{$model.id}" 
                            <php>if($model['id'] == $info['model']) echo 'selected="selected"';</php> >
                            {$model.title}
                        </option>
                    </volist>
                </select>
            </div>
        </div>
        <div class="form-group url <php>if($info['model'] != 1) echo 'hidden';</php>">
            <label class="item-label">链接<span class="check-tips">（U函数解析的URL或者外链）</span></label>
            <div class="controls">
                <input type="text" class="form-control" name="url" value="{$info.url|default=''}">
            </div>
        </div>
        <div class="form-group content <php>if($info['model'] != 2) echo 'hidden';</php>">
            <label class="item-label">内容<span class="check-tips">（单页模型填写内容）</span></label>
            <div class="controls">
                <textarea class="form-control" name="content">{$info.content|default=''}</textarea>
                <script type="text/javascript" src="__PUBLIC__/kindeditor/kindeditor-min.js" charset="utf-8"></script>
                <script type="text/javascript" src="__PUBLIC__/kindeditor/lang/zh_CN.js" charset="utf-8"></script>
                <script type="text/javascript">
                    var editor_content;
                    KindEditor.ready(function(K) {
                        editor_content = K.create('textarea[name="content"]', {
                            allowFileManager : true,
                            width: '100%',
                            height: '500px',
                            cssPath : [
                                '__PUBLIC__/zui/css/zui.min.css',
                                '__PUBLIC__/kindeditor/plugins/code/prettify.css'
                            ],
                            resizeType: 1,
                            pasteType : 2,
                            urlType : 'absolute',
                            items : [{:C('EDITOR_STYLE_DEFAULT')}],
                            fileManagerJson : '{:U("Index/fileManager")}',
                            uploadJson : '{:U("Index/upload")}',
                            remoteImgSaveUrl: '{:U("Index/downremoteimg")}',
                            extraFileUploadParams: {
                                session_id : '{:session_id()}'
                            },
                            afterBlur: function(){this.sync();},
                            autoSaveMode:true,
                            autoSaveInterval:100,
                            afterCreate: function() {
                                this.loadPlugin('autosave');
                            }
                        });
                    });
                </script>
            </div>
        </div>
        <div class="form-group">
            <label class="item-label">模版<span class="check-tips">（单页使用的模版或其他模型文档列表模版）</span></label>
            <div class="controls">
                <input type="text" class="form-control" name="template" value="{$info.template|default=''}">
            </div>
        </div>
        <div class="form-group">
            <label class="item-label">图标<span class="check-tips">（分类图标）</span></label>
            <div class="controls">
                <select class="chosen-icon" name="icon" data-value="{$info.icon|default=''}"></select>
            </div>
        </div>
        <div class="form-group">
            <label class="item-label">排序<span class="check-tips">（用于分组显示的顺序）</span></label>
            <div class="controls">
                <input type="text" class="form-control" name="sort" value="{$info.sort|default=0}">
            </div>
        </div>
        <div class="form-group">
            <input type="hidden" name="id" value="{$info.id|default=''}">
            <button class="btn btn-primary submit ajax-post" type="submit" target-form="form">确 定</button>
            <button class="btn return" onclick="javascript:history.back(-1);return false;">返 回</button>
        </div>
    </form>
</block>

<block name="script">
    <script type="text/javascript">
        //选择模型时页面元素改变
        $(function(){
            $('select[name="model"]').change(function(){
                var model_id = $(this).val();
                if(model_id == 1){ //超链接
                    $('.url').removeClass('hidden');
                    $('.content').addClass('hidden');
                }else if(model_id == 2){ //单页文档
                    $('.url').addClass('hidden');
                    $('.content').removeClass('hidden');
                }else{
                    $('.url').addClass('hidden');
                    $('.content').addClass('hidden');
                }
            });
        });
    </script>
</block>
